<?php
include_once 'Controlador/Error.php';

class DA_ArchReporte{
	private $rutaCompleta = null;
	private $nombre = null;
	private $extension = null;
	private $lineas = null;
	private $numLineas = null;
	private $error = null;
	const MODO_LEER = 'r';
	
	public function DA_ArchReporte($rutaCompleta){
		$this->rutaCompleta = $rutaCompleta;
		$infoArch = pathinfo($rutaCompleta);
		$this->nombre = $infoArch['filename'];
		$this->extension = $infoArch['extension'];
	 	$this->lineas = array();
	 	
		$handle = fopen($rutaCompleta, self::MODO_LEER); 
		if ($handle) { 
		   	while (!feof($handle)) { 
		   	   	$linea = trim(str_replace("\x00", "", fgets($handle)));
		   	   	if(!empty($linea)){
		   	   		$this->lineas[] = $linea;		   	   	
		   		}		       		       
		   	} 
		   	fclose($handle);
		   	$this->numLineas = count($this->lineas);
 		   	$this->error = new Error(TipoError::SIN_ERRORES); 
		}
		else{
			$this->error = new Error(TipoError::PHP_SIST_ARCH_FOPEN,'Archivo: '.$this->nombre);
		}	 			
	}
		
	public function getRutaCompleta(){
		return $this->rutaCompleta;
	}
	public function getNombre(){
		return $this->nombre;
	}
	public function getLineas(){
		return $this->lineas;
	}
	public function getNumLineas(){
		return $this->numLineas;
	}
	public function getExtension(){
		return $this->extension;
	}
	public function getError(){
		return $this->error;
	}	
	public function hayError(){
		return $this->error->hayError();
	}
	
}